﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Media;

namespace CPPEI.Coolzon.UI
{
    /// <summary>
    /// 竖直栈布局
    /// </summary>
    public class VStackLayout : Layout
    {
        private DockPanel _panel;
        private PartFrame _centerFrame;
        public VStackDirectionMode DirectionMode { get; set; }

        public VStackLayout()
        {
            DirectionMode = VStackDirectionMode.BottomToTop;
        }

        public override void AttachToPart(ILayoutContainer part)
        {
            _panel = new DockPanel();
            _panel.LastChildFill = true;
            part.SetLayout(this);
        }

        protected override void OnAddFrame(string position, PartFrame frame)
        {
            if (DirectionMode == VStackDirectionMode.BottomToTop)
            {
                _panel.Children.Add(frame);
                DockPanel.SetDock(frame, Dock.Top);
            }
            else
            {
                _panel.Children.Add(frame);
                DockPanel.SetDock(frame, Dock.Bottom);
            }
        }

        public override object GetUIContent()
        {
            return _panel;
        }

        public override void AddPart(System.Windows.Point position, Part part)
        {
            throw new NotImplementedException();
        }
    }
}
